<template>
  <div class="upload_wrap">
    <el-upload
      action="#"
      list-type="picture-card"
      multiple
      :limit="9"
      :file-list="value"
      :auto-upload="false"
      :on-preview="handlePreview"
      :on-remove="removeImg"
      :on-change="changImg"
    >
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="" />
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    value: Array,
  },
  data: () => ({
    dialogVisible: false,
    dialogImageUrl: ''
  }),
  methods: {
    // 添加图片
    changImg(_, fileList) {
      this.$emit("input", fileList);
    },
    // 移除图片
    removeImg(_, fileList) {
      this.$emit("input", fileList);
    },
    handlePreview(file) {
      console.log(file);
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
  },
};
</script>

<style></style>
